home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / lib / calc / varargs.cal < prev    next >
Text File  |  1995-07-17  |  537b  |  30 lines

  1. /*
  2.  * Copyright (c) 1993 David I. Bell
  3.  * Permission is granted to use, distribute, or modify this source,
  4.  * provided that this copyright notice remains intact.
  5.  *
  6.  * Example program to use 'varargs'.
  7.  *
  8.  * Program to sum the cubes of all the specified numbers.
  9.  */
  10.  
  11. define sc()
  12. {
  13.     local s, i;
  14.  
  15.     s = 0;
  16.     for (i = 1; i <= param(0); i++) {
  17.         if (!isnum(param(i))) {
  18.             print "parameter",i,"is not a number";
  19.             continue;
  20.         }
  21.         s += param(i)^3;
  22.     }
  23.     return s;
  24. }
  25.  
  26. global lib_debug;
  27. if (lib_debug >= 0) {
  28.     print "sc(a, b, ...) defined";
  29. }
  30.